home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
029a
/
chg202.zip
/
CHANGE.DOC
next >
Wrap
Text File
|
1991-12-01
|
27KB
|
549 lines
CHANGE User Manual
Utility: CHANGE v2.02
Date: 24-Nov-1991
Last Update: 18-Mar-1991
This work is (c) Copyright 1989'90'91 by:
John W. Clinton
P.O. Box 678 Bix Mail Id : JClinton
Boston, MA 02136 CompuServe Account: 70244,1340
Telephone : (617) 364-4515
All rights reserved.
Please pass this software around to your friends and associates. Feel
free to use this software for a month. If you find CHANGE as useful as
I do, please Register!. Full registration is only $25.00 in U.S. funds.
Registered Users receive the latest advertisement-free version of the
software via Bix, CompuServ or return mail and will receive all updates
made to CHANGE for 1 year from the date of registration. Updates have
been averaging one every four to six months. Registered versions of
the software are smaller and run faster, they do not have any of the
advertising or other annoying banners, all of the output may be
redirected using DOS redirection operators or may be suppressed
completely. Any special modifications you may require are available to
registered users by special arrangement. As a matter of policy I do
not currently make the source for CHANGE available to anyone.
Help support the Shareware Concept!
Disclaimer:
This software is provided 'as is' and is without any warranty of any
kind, whether express or implied, including, but not limited to the
implied warranties of fitness for a particular purpose. I will not be
liable for any special, indirect, incidental, consequential or similar
damages due to any loss of any kind related to the use of this software
or for any other reason, even if I or an agent of mine has been advised
of the possibility of such damages. In no event shall my liability for
any damages ever exceed the price paid for the license to use software,
regardless of the form of the claim. The person choosing to use the
software assumes any and all risks as to the quality and performance of
the software.
Acknowlegements:
Special thanks to my wife Loretta for putting up with all of the time I
put in on these little projects.
Thanks to Roedy Green for his constructive feedback on the program and
documentation.
Description:
CHANGE allows you to make global changes to the contents of files. It
works in much the same way as your favorite word processors global
1
CHANGE v2.02
change feature.
There are two major differences.
o The change(s) can be propagated through all of the files in a set
of comma delimited wildcard filespecs on the command line. This can
include all files in all subdirectories of the current subdirectory
or every directory on all disks attached to the system.
o You may specify many changes to be made with one pass through the
file(s).
This utility is indispensable when:
o Working with a large number of source files and you need to change
variable or function names, literals, etc. globally.
o Working on old code and you want to retrofit it with new naming
standards to bring the code up to date.
o Anytime there are a large number of files and a large number of
changes that need to be made quickly.
Usage
If no parameters are passed in to CHANGE a usage summary will be
printed. Additional help is available by using the /HELP switch.
In general:
Usage:
CHANGE <filespeclist> <matchString> <replacementString> [...] [/switches]
CHANGE - locates all occurances of the specified file(s) and replaces
the search string(s) with the specified replacement string(s).
Each filespec in the <filespeclist> may contain a drive, path and
filename. The drive is the volume that will be searched. All files
matching the files in the <filespeclist> will be search and modified as
needed.
Examples:
CHANGE *.c 'aa' 'bb'
Change all C sources in the current directory. Make 'aa' into 'bb'.
CHANGE SRC\*.C,INC\*.H,TMP\*.* 'foo','foobar'
Change all C source files in .\SRC, all Headers in .\INC and all
files in .\TMP. Make 'foo' into 'foobar'.
Search and Replace strings are single words or quoted strings. Either
single or double quotes will do. Everything on the command line is
uppercased unless surrounded by quotes. The Search and Replace
parameters may be separated by spaces or commas. If DOS redirection
characters are part of any string on the command line they MUST be
surrounded by DOUBLE QUOTES! That is the ONLY way to prevent DOS from
usurping them.
2
CHANGE v2.02
Currently supported switches:
(Only the upper case characters are required.)
/Help - Displays this message.
/ALL - Causes all fixed drives to be searched.
/SHow_context - Causes the line that matched to be displayed prior
to the change and prompts the user to confirm that specific change.
Changes may be allowed (Press 'Y'); Disallowed (press 'N' or RETURN);
Make all of the changes found from here to the end of this file,
(press ^Z); Make no more changes to this file, but keep the changes
made so far (press ESC); or abort the changes made to this file
completely, (press '^C'). Press ? for additional help at the CHANGE
prompt. The default is /NOSHow_context in CHANGE as shipped, See the
notes on the CHGINST program below.
/[NO]Prefix_change - Only make the CHANGE if the matchstring is at the
beginning of a string. Match 'thisx', not 'xthisx' or 'xthis'.
/[NO]SUffix_change - Only make the CHANGE if the matchstring is at the
end of a string. Match 'xthis', not 'xthisx' or 'thisx'.
/[NO]Whole_words - Only make a CHANGE if the matchstring is a whole
surrounded by nonalphanumerics. Match 'this', not 'xthis' or 'thisx'.
/[NO]Subdirectories - Causes all subdirectories of the current one to be
searched.
The default is /NOSUbdirectories in CHANGE as shipped, See the notes on the
CHGINST program below.
/[NO]Case_sensitive - Allows the searching to be performed respecting
the case of the match and replacement strings.
The default is /NOCASE_SENSITIVE in CHANGE as shipped, See the notes on the
CHGINST program below.
/[NO]Unique_bak - Guarantees that backup files created will be unique.
This will prevent CHANGE from deleting a backup file that already
exists. CHANGE automatically enables this option when wildcard
filespecs (like TEST.*) are specified that can overwrite backup files
that CHANGE just created.
The default is /Unique_bak in CHANGE as shipped, See the notes on the
CHGINST program below.
/Binary_file - This option allows files containing <EOF> characters
or search strings that span <CR><LF> sequences to be processed.
/Text_file and /Binary_file are mutually exclusive, /Binary_file takes
precedence if both are found on the command line.
This is a synonym for /NOText_file
/Binary_file is the default in CHANGE as shipped, See the notes on
the CHGINST program below.
/Text_file - This option processes files about 2 times faster
than Binary_file mode. => Note the restrictions listed below.
3
CHANGE v2.02
This is a synonym for /NOBinary_mode
/[NO]Floppysize=n - Defines the size in KB of the largest floppy on
your system you want searched. By default drives a: and B: are not
checked at all. EX: /ALL/FLOPPYSIZE=1200 would check the size of each
drive before searching. Only those 1.2MB and up would be searched.
/[NO]COnfirm_change - Prompts for permission to make changes to each
FILESPEC matched that actually contains a match. This allows the user
to selectively modify files.
/ANy_attribute - Change all files matching the FILESPEC, regardless
of special file attributes. /CONFIRM_CHANGE option is set by default,
but may be overridden.
/[NO]Log - Do [NOT] write progress messages to the console.
The default is /NOLog in CHANGE as shipped, See the notes on the
CHGINST program below.
/[NO]BACKups - Do [NOT] rename the original files to .BAK.
The default is /BACKups in CHANGE as shipped, See the notes on the
CHGINST program below.
CHANGE is now being shipped with a utility called CHGINST. (new as of
v2.00)
This program allows you to reconfigure the defaults of the most commonly
used (but not all) switches to suit your own specific needs.
To use CHGINST just run it from the command line. It will search for
CHANGE in the current directory and along the DOS PATH. If change
cannot be found it will stop and suggest the following:
Either move CHANGE into the same directory with CHGINST, move CHANGE
into a directory along your DOS PATH, or invoke CHGINST with the name of
the directory that CHANGE is in as a parameter.
Ex:
CHANGE is in C:\NEWSTUFF and CHGINST is in C:\ use
CHGINST -> if C:\NEWSTUFF is in your PATH,
CHGINST C:\NEWSTUFF -> if C:\NEWSTUFF is NOT in your PATH.
Note:
CHGINST DOES depend on CHANGE being called CHANGE.EXE!
General command line handling:
Switches may be placed anywhere on the command line except within quoted
strings. Switches may be abbreviated to the smallest unique string
among the switches the program supports.
The minimum number of characters required for each of the switches is
indicated by the uppercase part of the switch names on the help screen.
Everything on the command line is converted to uppercase unless
surrounded by quotes. Both double (") and single (') quotes are
4
CHANGE v2.02
supported. If your string(s) contain the DOS re-direction operators < >
or | then you MUST enclose the string in DOUBLE QUOTES! Double Quotes
will prevent DOS from using them for redirection of the standard
input/output files. The console output of CHANGE may be redirected.
Non printable characters may be placed into the quoted strings on the
command line or in indirect files (discussed below) using the following
syntax: #nnn or ^a where 'nnn' is the Decimal ASCII code for the desired
character and 'a' is '@'..'Z' corresponding to ^@ through ^Z. If the
end of line characters of a text file (CR and/or LF) are being modified
the file MUST be converted in /BINARY_MODE (the default).
Ex. ^G - also the ASCII BEL character.
5#0075 - would be converted to 5's surrounding a BEL.
x#7x - would be converted to x's surrounding a BEL.
The leading zeros are required in ex. 3 to keep the other numbers from
confusing CHANGE. They may be omitted when there is only one way to
interpet the data. These special characters may appear in your data as
long as they are unambiguous. When in doubt, use two special characters
to get one. See the examples below.
Normally the DOS command line supports parameters up to 128 bytes.
Indirect parameter files may be used for changes that either require
more than 128 bytes of input OR may be used many times in the future.
The total size of the the parameter string may now exceed 60KB.
Indirect Parameter Files:
To use an indirect file place an '@' at the beginning of the name of the
indirect file on the command line. The indirect file itself may contain
anything that is normally allowed on the command line for CHANGE.
Switches specified in the indirect file may be overridden or added to by
specifying the new switches on the command line following the indirect
file's name.
CHANGE TEST.PAS @varchang.lis /SUBDIR
This would include the list of change strings found in the file
VARCHANG.LIS in the current directory. The lines in the file are
concatenated together with a space appended to the end of each line. If
the resulting command line has an uneven number of CHANGE strings
specified an error will be reported.
Ex: 1. To rename the ever popular 'foobar' variable to 'MyVar' in the
program 'test.pas' you would use the following CHANGE command:
CHANGE test.pas 'foobar' 'MyVar'
2. To do the same in all of your Pascal files in a given directory
you would use: CHANGE *.pas 'foobar' 'MyVar'
3. To do the same in all of your Pascal files on a given drive you
would use: CHANGE *.pas 'foobar' 'MyVar' /all
4. To change foobar to #@^foobar (use of special chars) double up
the special chars. Use: CHANGE *.pas 'foobar' '##^^@@foobar'
5
CHANGE v2.02
4. To change strings that contain special characters you need to
represent the special characters in some fashion and 'allow'
CHANGE to see them. Any character in the ASCII set may be
specified in a QUOTED STRING by using a # followed by the
character's three digit decimal ASCII code, for instance #007
is the BEL character.
To reformat a LF delimited text file into a more standard CRLF
delimited file use the following:
CHANGE STRANGE.C ^J ^M^J
5. To change instances of a string only at the start or end of a
line use:
CHANGE text.fil 'EndString' 'NewEndString'/Prefix
CHANGE text.fil 'StartString' 'NewStartString'/SUffix
6. Several CHANGEs may be combined. The following CHANGE turns
the variables called 'var1' into 'MyOtherVar' and reformats a
LF delimited text file to a CRLF delimited text file.
CHANGE *.pas 'foobar' 'MyVar' 'var1' 'MyOtherVar' #10 #13#10
7. If you have a large or complex change like the one above it is
often better to use an indirect file. The indirect file,
'BIGCHG.IND', for that change would look like this:
! Comments are allowed within indirect files.
! They are lines that being with an '!'
'foobar' 'MyVar'
'var1' 'MyOtherVar'
#10 #13#10
And the invocation of CHANGE would be:
CHANGE *.PAS @BIGCHG.IND
Change History
The following changes have been made to CHANGE since it's original
release:
1. v1.00 - initial release.
2. V1.01 - New features and minor bugfixes:
o Added /BINARY_MODE.
o Speeded up the /TEXT_MODE operation.
o Added multiple match,replace string capability.
o made a bugfix the error recovery.
3. V1.02 - New features:
o Add /ANY_ATTRIBUTE.
o Add /CONFIRM_CHANGE.
o Released as Shareware.
6
CHANGE v2.02
4. V1.03 - New features:
o Fixed display of files as each is completed the name is
left on a line of it's own.
o Now when a file is scanned, but has no matches it is NOT
updated. Previously ALL files that were looked at were
marked as updated.
5. V1.04 - New features:
o /SUB now causes matching files in the current or specified
directory and it's sub-directories to be processed.
o A new /SHOW_CONTEXT switch to:
- display the LINE that is about to be changed.
- allow the user to confirm changes on an item by item
basis.
o A new /WHOLE_WORDS switch to only match when the string is
surrounded by non-alphanumerics.
o a new /[NO]LOG switch has been added to allow the user to
specify that progress messages should [NOT] be written to
the console. The default is /LOG.
o a new /[NO]UNIQUE_BAK switch has been added to allow the
user to specify that CHANGE should not overwrite any
existing .BAK files. Now if there is a conflict CHANGE
attempts to use .BAL then .BAM etc...
o bug fixes:
o In previous versions if you attempted to CHANGE a text file
that was not CRLF delimited without using /BINARY_MODE the
output file would be truncated to 257 bytes. This has been
trapped for and a warning is issued allowing you to
allow/disallow saving the changes made.
A backup file has always been made to presere the original
file.
o In previous versions if you made a change with a wildcard
t
filespec that like TEST. to process TEST.001, TEST.002,
etc. the backup files would be created on top of one
another. CHANGE would only leave the backup file for the
f
last TEST. file processed intact. Now the /UNIQUE_BAK
option is enabled when this situation is detected.
o In previous versions if you made a change with a wildcard
,
filespec that included backup files (ex. TEST., TEST.B??)
CHANGE would loop back around and process the backup files
as well. This situation is now detected and informs you of
the problem and warns you that if you decide to proceed
CHANGE will NOT CREATE BACKUP FILES for the files changed.
6. V1.05 - New features:
o When using the /SHowcontext switch there are some new
responses that are allowed. Pressing ESC will cause the
rest of the file to be copied with out any more changes
being made. No more prompting will be done. The changes
that have been allowed to date will be saved. Pressing Z
will cause the rest of the file to be copied APPLYING all
of the changes to the rest of the file without any more
prompting.
In either of these cases prompting for each change will
resume in the next file to be processed if the changes are
being made to a wildcard list of files.
o Optimized the io buffer sizes for Maximum io performance.
o Optimized the code for speed in the critical areas and for
size elsewhere.
7
CHANGE v2.02
7. v2.00 - New features and modifications:
o rewrote /Binary_file for speed.
o Changed /Text_file to be the optional mode. /Text_file is
faster, but it does not handle files containing binary data
gracefully. Use /Text_file for making the fastest changes
possible to CRLF delimited text files.
o Enabled /WHolewords in /Binary_file.
o Enabled /SHowcontext for /Binary_file.
o Greatly improved the way the context is displayed.
o Removed /SHowcontext feature from /Text_file.
o Added /Prefix and /SUffix to both /Text_file and
/binary_file.
When /SUffix is specified 'this' will match 'xthis' but not
'this' or 'xthisx' or 'thisx'. When /Prefix is specified
'this' will match 'thisx' but not 'this' or 'xthisx' or
'xthis'. The /WHolewords switch implies BOTH /SUffix and
/Prefix.
8. v2.01 - New features and modifications:
o In addition to wildcards, the command line now supports
comma-delimited lists of filenames. This will allow files
with extremely different names to be processed in one pass.
o The command line was limited to 255 characters. This
restriction has been increased to 64K.
The insertion of control characters has been enhanced to
allowing x#1x x#01x and x#001x all to be converted to a ^A.
^A is also supported for entering control characters. To
enter a # or ^ use two of them in succession: x##1x -> x#1x.
o Added a /[NO]BACKUPS switch to allow the user to select not
to create backups. - NOT RECOMMENDED, but sometimes
expedient.
o Fixed a bug in the /unique_bak extension routines.
It would rename the datafile into a backup file inside the
\$TEMP!.@$ directory.
o CHANGE D:\*.BAT .... would crash if the default drive was
NOT D:. - Fixed.
o The /TEXT/SH combination was exiting without any action at
all. Now it switches to /Binary_mode and continues
normally. /Text_mode does not support /SHOW_CONTEXT.
o The /SHOW_CONTEXT display would wander randomly from hex to
ascii. Now the display always shows a hexdump. Pressing
'A' will switch to an ASCII display.
o In /Confirm the file name was not being displayed. - Fixed.
o /Confirm would originally give no indication it responded.
Now the heading for the context window shows the offset into
the file. This is updated with each redisplay of the window.
9. v2.02 - New features and modifications:
o Now switches will match uniquely.
o Switches that are unknown force the help screen to pop up.
o Fixed a small problem when specifying directory names in
/NOALL mode.
o In /SHow the filenames are being clobbered when successive
filenames are shorter. - Fixed.
o Added a help screen to /SHow_context. Access with '?'.
8
CHANGE v2.02
Known Problems:
The following problems are known to exist in this version:
1. When CHANGE is used on a file that had DOS file protection bits
set, the protection bits are LOST! When CHANGE finds one of
these files and it is told it is Ok to change it, CHANGE sets
the file's protection to ARCHIVE only. When the original file
is renamed to the .BAK version it is left with just the ARCHIVE
bit set. The new version of the file is set to ARCHIVE only.
It is left up to the User to reset the file protection
appropriately.
I don't view this as a problem, but you should be aware of it.
2. When running CHANGE on a Netware file volume you must have the
privleges required to edit the files and to create a
subdirectory off the directory containing the files to be
CHANGEd.
3. When using /WHOLE_WORDS or the prefix switches it is possible
to confuse the pattern matcher. An error is generated warning
you that not all requested changes were made. There is no the
/BACKup status is changed to /BACKup to ensure that you can
recover and processing continues. I have yet to have anyone
report running into this message in normal use.
Planned Changes:
I will be rewriting the main (/BINARY) change loop in ASM to speed
it up. The goal is to eliminate the need for the /TEXT mode
entirely. This change will also cut about 15% off of the current
size of CHANGE.EXE.
CHANGE is currently 98% Pure Turbo Pascal.
If I get enough requests I will be adding unix grep style 'regular
expression' pattern matching. If you need this please let me know!
Barring the unexpected these will be released as a part of v2.03
sometime in the spring-summer of 1992.
ENCOUNTERING PROBLEMS:
If you wish to report a problem with this software I can be reached at
the above address, or send electronic mail to me via Bix (JClinton) or
CompuServe (70244,1340). Please provide as much detail into the nature
of the problem encountered, along with the system configuration details.
Telephone Support is now available for registered users at
(617) 364-4515 Monday through Friday between 8am and 5pm EST.
As always I am welcome new ideas, comments and suggestions!
9